package com.trinity.uniquefees.dto;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import lombok.Data;
import lombok.ToString;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 订购教程名单对象 uf_student_book
 *
 * @author 董诗攀
 * @date 2023-12-11
 */
@Data
@ToString
public class UfStudentBookDto implements Serializable {

    private static final long serialVersionUID = 1L;

    private Long studentId;

    private String stuNo;

    private String studentName;

    private Set<CourseDto> courses;

    private String totalPrice;

    public static String getStringCourse(Set<CourseDto> courseDtoSet) {
        List<Map<String, Object>> goods = new ArrayList<>();
        for (CourseDto course : courseDtoSet) {
            Map<String, Object> good = new JSONObject();
            good.put("goodsId", course.getCourseId());
            good.put("goodsType", "book");
            good.put("goodsName", course.getCourseBook());
            good.put("goodsPrice", course.getPrice());
            good.put("goodsDetail", course.isSubscribe());
            goods.add(good);
        }
        return JSON.toJSONString(goods);
    }
}
